package org.qdao.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = ElementType.FIELD)
public @interface Column {

	String name();

	DBColumnType type();

	String description() default "";

	int length() default -1;

	int decimal() default 0;

	boolean nullable() default true;
	
	boolean autoIncrement() default false;
	
	String defaultValue() default "";
	
	static public enum DBColumnType {
		ARRAY(java.sql.Types.ARRAY),
		BIGINT(java.sql.Types.BIGINT),
		BINARY(java.sql.Types.BINARY),
		BIT(java.sql.Types.BIT),
		BLOB(java.sql.Types.BLOB),
		BOOLEAN(java.sql.Types.BOOLEAN),
		CHAR(java.sql.Types.CHAR),
		CLOB(java.sql.Types.CLOB),
		DATE(java.sql.Types.DATE),
		DATETIME(java.sql.Types.TIMESTAMP),
		DECIMAL(java.sql.Types.DECIMAL),
		DISTINCT(java.sql.Types.DISTINCT),
		DOUBLE(java.sql.Types.DOUBLE),
		FLOAT(java.sql.Types.FLOAT),
		INTEGER(java.sql.Types.INTEGER),
		JAVA_OBJECT(java.sql.Types.JAVA_OBJECT),
		LONGVARBINARY(java.sql.Types.LONGVARBINARY),
		LONGVARCHAR(java.sql.Types.LONGVARCHAR),
		NULL(java.sql.Types.NULL),
		NUMERIC(java.sql.Types.NUMERIC),
		OTHER(java.sql.Types.OTHER),
		REAL(java.sql.Types.REAL),
		REF(java.sql.Types.REF),
		SMALLINT(java.sql.Types.SMALLINT),
		STRUCT(java.sql.Types.STRUCT),
		TIME(java.sql.Types.TIME),
		TIMESTAMP(java.sql.Types.TIMESTAMP),
		TINYINT(java.sql.Types.TINYINT),
		VARBINARY(java.sql.Types.VARBINARY),
		VARCHAR(java.sql.Types.VARCHAR),
		VARCHAR2(java.sql.Types.VARCHAR),
		DATALINK(java.sql.Types.DATALINK),
		ROWID(java.sql.Types.ROWID),
		LONGNVARCHAR(java.sql.Types.LONGNVARCHAR),
		NCHAR(java.sql.Types.NCHAR),
		NCLOB(java.sql.Types.NCLOB),
		NVARCHAR(java.sql.Types.NVARCHAR),
		NVARCHAR2(java.sql.Types.NVARCHAR),
		NUMBER(java.sql.Types.NUMERIC),
		SQLXML(java.sql.Types.SQLXML);
		private int type;

		public int value() {
			return type;
		}

		private DBColumnType(int type) {
			this.type = type;
		}

		public static void main(String args[]) {
			Column.DBColumnType type = Column.DBColumnType.ROWID;
			System.out.println(type.value());
		}
	}
}
